<template>
  <div id="cart">
    <headers>
      <div slot="conter">购物车({{ cartList.length }})</div>
    </headers>

    <div class="cart-list">
      <ul>
        <li v-for="(item, index) in cartList" :key="index">
          <div class="top">
            <i
              class="iconfont icon-xuanze"
              v-if="!item.checked"
              @click="select(index)"
            ></i>
            <i class="iconfont icon-xuanze1 check" v-else></i>
            <span>{{ item.name }}</span>
          </div>
          <div class="content">
            <div class="icon">
              <i class="iconfont icon-xuanze" v-if="!item.checked"></i>
              <i class="iconfont icon-xuanze1 check" v-else></i>
            </div>
            <div class="shop-info">
              <img :src="item.image" alt="" />
              <div class="text">
                <h3>{{ item.title }}</h3>
                <div class="moner">
                  <div class="price">￥{{ item.newPrice }}</div>
                  <div class="count">
                    <i class="iconfont icon-jiajian-jian"></i>
                    <span>{{ item.count }}</span>
                    <i class="iconfont icon-jiajian-jia"></i>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </li>
      </ul>
    </div>

    <div class="check-out">
      <div class="all">
        <i class="iconfont icon-xuanze"></i>
        <!-- <i class="iconfont icon-xuanze1 check"></i> -->
        <span>全选(0)</span>
      </div>
      <div class="price">
        <div>￥0.00</div>
        <button>结算</button>
      </div>
    </div>

    <Footer class="bottom-bar"></Footer>
  </div>
</template>

<script>
import Footer from '../../components/content/Footer'
import Headers from '../../components/content/Headers'

import { mapState } from 'vuex'

export default {
  data() {
    return {}
  },
  components: {
    Headers,
    Footer
  },
  computed: {
    ...mapState(['cartList'])
  },
  mounted() {
  },
  methods: {
    select(index) {
      this.cartList[index].checked = !this.cartList[index].checked
    }
  }
}
</script>

<style lang="less" scoped>
#cart {
  height: 100vh;
  overflow: hidden;
  .check {
    color: var(--color-a);
  }
  .cart-list {
    height: 100%;
    padding: 10px;
    background-color: #f5f5f5;
    li {
      padding: 10px;
      margin-bottom: 10px;
      background-color: #fff;
      border-radius: 5px;
      .top {
        display: flex;
        font-size: 14px;
        margin-bottom: 10px;
        span {
          margin-left: 10px;
          color: #333;
        }
      }
    }
    .content {
      display: flex;
      align-items: center;
      overflow: hidden;
      .shop-info {
        display: flex;
      }
      img {
        width: 60px;
        margin: 0 10px;
      }
      .text {
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        h3 {
          font-size: 14px;
          font-weight: 400;
        }
        .price {
          color: orangered;
          font-size: 17px;
        }
        .moner {
          display: flex;
          justify-content: space-between;
          span {
            margin: 0 5px;
            font-size: 17px;
            color: #333;
          }
          .count {
            display: flex;
            align-items: center;
          }
          .iconfont {
            font-size: 19px;
            padding: 0 5px;
          }
        }
      }
    }
  }
}

.check-out {
  position: relative;
  bottom: 132px;
  display: flex;
  justify-content: space-between;
  padding: 5px 10px;
  background-color: #fff;
  .all {
    display: flex;
    align-items: center;
    span {
      margin-left: 3px;
      font-size: 14px;
    }
  }
  .price {
    display: flex;
    align-items: center;
    font-size: 15px;
    button {
      border: none;
      padding: 5px 15px;
      border-radius: 15px;
      color: #fff;
      margin-left: 10px;
      background-color: var(--color-tint);
    }
    div {
      color: red;
    }
  }
}

.bottom-bar {
  background-color: #fff;
  box-shadow: 1px 1px 10px 3px #eee;
}
</style>
